--
--  Basic_apple_scriptAppDelegate.applescript
--  Basic apple script
--
--  Created by Josef on 20/12/2010.
--  Copyright 2010 __MyCompanyName__. All rights reserved.
--

script Basic_apple_scriptAppDelegate
	property parent : class "NSObject"
	
	on buttonHello_(aNotification)
		tell application "Basic apple script"
			activate
		end tell
		tell application "System Events"
			keystroke "Hello World"
			key code 36
		end tell
	end buttonHello_
	
	on buttonGoodbye_(aNotification)
		tell application "Basic apple script"
			activate
		end tell
		tell application "System Events"
			keystroke "a" using command down
			key code 51
		end tell
	end buttonGoodbye_
	
	on buttonSpeak_(aNotification)
		display dialog "What do you want your mac to say?" default answer "" buttons {"OK"} default button 1
		set speakVariable to the text returned of the result
		tell application "Finder"
			do shell script "say " & speakVariable
		end tell
	end buttonSpeak_
	
	on applicationWillFinishLaunching_(aNotification)
		tell application "Basic apple script"
			activate
		end tell
		tell application "System Events"
			keystroke "Welcome"
		end tell
	end applicationWillFinishLaunching_
	
	on applicationShouldTerminate_(sender)
		-- Insert code here to do any housekeeping before your application quits 
		return current application's NSTerminateNow
	end applicationShouldTerminate_
	
end script